package com.pariyani.service.impl;

import br.com.vantagensaki.utils.BaseService;
import br.com.vantagensaki.utils.exception.ObjetoNaoEncontradoException;
import javax.inject.Inject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.pariyani.dao.UserDao;
import com.pariyani.service.UserService;
import com.pariyani.user.User;

/**
 * @author Imran Pariyani
 * 
 * {@link http://pariyani.com} pariyani
 */
@Service
public class UserServiceImpl 
        //extends BaseService
        implements UserService {

    private final UserDao userDao;

//    private JavaMailSender javaMailSender;
//

    @Inject
    UserServiceImpl(UserDao userDao) {
        this.userDao = userDao;
    }

//    public UserServiceImpl() {
//        super(UserServiceImpl.class);
//    }
//    @Inject
//    UserServiceImpl(UserDao userDao,JavaMailSender javaMailSender) {
//        this.userDao = userDao;
//        this.javaMailSender = javaMailSender;
//        if (this.javaMailSender != null) {
//            this.sendMailExeService = Executors.newFixedThreadPool(5);
//        }
//    }

//    private ExecutorService sendMailExeService;

    @Transactional(readOnly = true)
    public User getUser(int userId) throws ObjetoNaoEncontradoException {
        return userDao.getUser(userId);
    }

//    class SendMailRunnable implements Runnable {
//        private MimeMessage message;
//
//        private JavaMailSender mailSender;
//
//        SendMailRunnable(MimeMessage message  ,JavaMailSender mailSender) {
//            this.message = message;
//            this.mailSender = mailSender;
//        }
//
//        public void run() {
//            try {
//                if (mailSender != null && message != null) {
//                    mailSender.send(message);
//                }
//            } catch (Throwable zzz) {
//                zzz.printStackTrace();
//            }
//        }
//    }
}
